﻿package  {
	
	import flash.display.MovieClip;
	
	
	public class Spring extends MobObj {
		
		
		private var player:Player;
		
		public function Spring(aX:Number,aY:Number,p:Player) {
			super(aX,aY,width,height);
			player = p;
			
		}
		
		protected override function CollisionX():Boolean
		{
			var go:Boolean = true;
			var nextX:int = 0;
			nextX = x;
							
		
			nextX += width;
			
			
			for(var i:int = 0; i < player.tiles.length; i++){
					if(player.tiles[i].CollisionCheck(nextX, y) && this.stage)
					{
						trace("sprung");
						player.Sprung = true;
						parent.removeChild(this);
					}
					if(player.tiles[i].CollisionCheck(nextX, y + height) && this.stage)
					{
						player.Sprung = true;
						parent.removeChild(this);
					}
			}
			return go;
			
		}
		
		protected override function CollisionY():Boolean
		{
			var go:Boolean = true;
			var nextY:int = 0;
			
			nextY = y;
				
			nextY += height;
			
			for(var i:int = 0; i < player.tiles.length; i++){
					if(player.tiles[i].CollisionCheck(x, nextY) && this.stage)
					{
						trace("sprung");
						player.Sprung = true;
						parent.removeChild(this);
					}
					if(player.tiles[i].CollisionCheck(x + width, nextY) && this.stage)
					{
						player.Sprung = true;
						parent.removeChild(this);
					}
			}
			return go;
		}
	}
	
}
